<?php
    $user = $this->user;
    $auth = $this->auth;
?>
<div class="container">
    <!-- start: Page Title Icon-->
    <div id="page-title-icon"></div>
    <div id="page-title-icon-inner">
        <i class="ico-text-resize ico-white"></i>
    </div>
    <!-- end: Page Title Icon-->
    <!-- start: Page Title -->
    <section id="page-title">
        <h2>Thông tin người dùng</h2>
    </section>
</div>
<div id="wrapper" class="white-wrapper">


    <div class="container">

        <!-- start: 4 Columns -->
        <div class="four columns">
            <img src="<?php echo $user->avatar; ?>">
        </div>
        <!-- end: 4 Columns -->

        <!-- start: 12 Columns -->
        <div class="twelve columns">

          <ul>
              <li><strong>Tên:</strong> <?php echo $user->name; ?></li>
              <li><strong>Email:</strong> <a href="mailto:<?php  echo $user->email; ?>"> <?php echo $user->email; ?></a></li>
              <li><strong>Địa chỉ:</strong> <?php echo $user->address; ?></li>
              <li><strong>Điện thoại:</strong> <?php echo $user->phone; ?></li>
              <li><strong>Sản phẩm:</strong> <a href="/user/topic/<?php echo $user->id; ?>">của <?php echo $user->name; ?></a> </li>

            <?php if($auth && $auth->userid != $user->id){ ?>
              <li>
                  <a class="button gray medium" href="/user/inbox/<?php echo $user->id; ?>">Nhắn tin</a>
                  <a class="button color medium" style="cursor: pointer" id="btn_addFriend">Kết bạn</a>
                  <a class="button light  medium" style="cursor: pointer" id="btn_followFriend">Theo dõi</a>
              </li>



              <?php } ?>			  <!-- from user -->              <input type="hidden"  id="_from_user_name" value="<?php if( $auth) echo $auth->name; ?>" />              <input type="hidden"  id="_form_user_email" value="<?php  if( $auth) echo $auth->email; ?>" />              <input type="hidden"  id="_form_user" value="<?php  if( $auth) echo $auth->userid; ?>" />              <!-- to user -->              <input type="hidden"  id="_to_user_name" value="<?php  if( $auth) echo $user->name; ?>" />              <input type="hidden"  id="_to_user_email" value="<?php  if( $auth) echo $user->email; ?>" />              <input type="hidden"  id="_to_user" value="<?php  if( $auth) echo $user->id; ?>" />
          </ul>
        </div>
        <!-- end: 12 Columns -->



    </div>
    <!-- end: Container -->



</div>


<script>
    /*  $("ul#nav").append('' +
     '<li id="addFriend"><a id="btn_addFriend">Add Friend</a></li>' +
     '<li id="followFriend"><a id="btn_followFriend">Follow</a></li>');            */
    $('#btn_addFriend').click(function(){
        AddFriend("0","friend");
        $("#btn_addFriend").remove();		$("#btn_followFriend").remove();
        return false;
    });
    $('#btn_followFriend').click(function(){
        AddFriend("1","follow");
        $("#btn_followFriend").remove();
        return false;
    });

    function AddFriend(type, content_aler){
        var _form_user = $("#_form_user").val();
        var _from_user_name = $("#_from_user_name").val();
        var _form_user_email = $("#_form_user_email").val();

        var _to_user_name = $("#_to_user_name").val();
        var _to_user_email =  $("#_to_user_email").val();
        var _to_user =  $("#_to_user").val();

        var _type_request = type;
        var _message_content = "You have 1 "+content_aler+" request from "+_from_user_name;
        var _is_accepted = "0";

        $.ajax({
            type: "POST",
            url: "/admin/user/addfriend",
            data: { form_user: _form_user,
                from_user_name: _from_user_name,
                form_user_email:_form_user_email,
                to_user_name: _to_user_name,
                to_user_email: _to_user_email,
                to_user : _to_user,
                type_request : _type_request,
                message_content : _message_content,
                is_accepted :_is_accepted
            }
        }).done(function(data){

                if(data == 1)
                {
                    var content = '<button type="button" class="close" data-dismiss="alert">×</button> <strong>Well Done</strong>  Your '+content_aler+' request has been sent.';
                    jsuccess('Bạn vừa gửi yêu cầu kết bạn thành công.');

                }
            });
    }
</script>